1
'*************************** Module Header ******************************'
2 ' Module Name: OpenImageMenuExt.vb
3 ' Project: VBCustomIEContextMenu
4 ' Copyright (c) Microsoft Corporation.
6 ' The class OpenImageMenuExt is used to add/remove the menu in registry when this
7 ' assembly is registered/unregistered.
10 ' This source is subject to the Microsoft Public License.
11 ' See http://www.microsoft.com/opensource/licenses.mspx#Ms-PL.
12 ' All other rights reserved.
14 ' THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
15 ' EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
16 ' WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
17 '*************************************************************************'
20 Imports System
.Reflection
21 Imports System
.Runtime
.InteropServices
22 Imports Microsoft
.Win32
24 Public Class OpenImageMenuExt
25 Private Const IEMenuExtRegistryKey
As String = _
26 "Software\Microsoft\Internet Explorer\MenuExt"
28 Public Shared
Sub RegisterMenuExt()
30 ' If the key exists, CreateSubKey will open it.
31 Dim ieMenuExtKey
As RegistryKey
= _
32 Registry
.CurrentUser
.CreateSubKey( _
33 IEMenuExtRegistryKey
& "\Open image in new Tab")
36 ' Get the path of Resource\OpenImage.htm.
37 Dim fileIofo
As New FileInfo(System
.Reflection
.Assembly
.GetExecutingAssembly().Location
)
38 Dim path
As String = fileIofo
.Directory
.FullName
& "\Resource\OpenImage.htm"
40 ' Set the default value of the key to the path.
41 ieMenuExtKey
.SetValue(String.Empty
, path
)
43 ' Set the value of Name.
44 ieMenuExtKey
.SetValue("Name", "Open_Image")
46 ' Set the value of Contexts to indicate which contexts your entry should
47 ' appear in the standard context menu by using a bit mask consisting of
48 ' the logical OR of the following values:
55 ieMenuExtKey
.SetValue("Contexts", &H2
)
60 Public Shared
Sub UnRegisterMenuExt()
61 Dim ieMenuExtskey
As RegistryKey
= _
62 Registry
.CurrentUser
.OpenSubKey(IEMenuExtRegistryKey
, True)
64 If ieMenuExtskey IsNot
Nothing Then
65 ieMenuExtskey
.DeleteSubKey("Open image in new Tab", False)